/**
 * 题目 api 封装
 *
 * @Author:    sweepingMonk
 * @Date:      2023-09-04 15:14:45
 * @Copyright  扫地僧
 */
import {getRequest, postRequest} from '/@/lib/axios';

export const questionApi = {

    /**
     * 分页查询  @author  sweepingMonk
     */
    queryPage: (param) => {
        return postRequest('/question/queryPage', param);
    },

    /**
     * 增加  @author  sweepingMonk
     */
    add: (param) => {
        return postRequest('/question/add', param);
    },

    /**
     * 修改  @author  sweepingMonk
     */
    update: (param) => {
        return postRequest('/question/update', param);
    },


    /**
     * 查询详情  @author  sweepingMonk
     */
    detail: (id) => {
        return getRequest(`/question/detail/${id}`);
    },
    /**
     * 删除  @author  sweepingMonk
     */
    delete: (id) => {
        return getRequest(`/question/delete/${id}`);
    },

    /**
     * 批量删除  @author  sweepingMonk
     */
    batchDelete: (idList) => {
        return postRequest('/brand/batchDelete', idList);
    },

};

export function formatQuestionInfo(type, value) {
    let name = '';
    if (type === 'grade') {
        switch (value) {
            case -1:
                name = 'N';
                break;
            case 0:
                name = 'S';
                break;
            case 1:
                name = 'A';
                break;
            case 2:
                name = 'B';
                break;
            case 3:
                name = 'C';
                break;
            case 4:
                name = 'D';
                break;
        }
    }
    if (type === 'choosable') {
        switch (value) {
            case 0:
                name = '不可选';
                break;
            case 1:
                name = '可选';
                break;
        }
    }
    if (type === 'selectType') {
        switch (value) {
            case 0:
                name = '单选';
                break;
            case 1:
                name = '多选';
                break;
        }
    }
    if (type === 'requiredFlag') {
        switch (value) {
            case 0:
                name = '非必选';
                break;
            case 1:
                name = '必选';
                break;
        }
    }
    return name;
}